Skip to content

Add support for PiP for FrontendScreen#6812

Open
TimoPtr wants to merge 3 commits intomainfrom
feature/pip
Open

Add support for PiP for FrontendScreen#6812
TimoPtr wants to merge 3 commits intomainfrom
feature/pip

Conversation

@TimoPtr
Copy link
Copy Markdown
Member

@TimoPtr TimoPtr commented May 5, 2026

Summary

Based on #6790 to add support for PiP in FrontendScreen using the LauncherActivity.

Checklist

  • New or updated tests have been added to cover the changes following the testing guidelines.
  • The code follows the project's code style and best_practices.
  • The changes have been thoroughly tested, and edge cases have been considered.
  • Changes are backward compatible whenever feasible. Any breaking changes are documented in the changelog for users and/or in the code for developers depending on the relevance.

@TimoPtr TimoPtr requested a review from jpelgrom May 6, 2026 06:56
@TimoPtr TimoPtr force-pushed the feature/custom_view branch from 7dff587 to a4fa47f Compare May 6, 2026 06:59
Base automatically changed from feature/custom_view to main May 6, 2026 07:33
Copilot AI review requested due to automatic review settings May 6, 2026 07:45
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the new Compose-based FrontendScreen (Frontend V2) to support entering Android Picture-in-Picture (PiP) mode via LaunchActivity, by reporting when PiP-eligible content is visible (fullscreen Media3/ExoPlayer overlay or a WebView custom view) and using that snapshot to enter PiP when the user backgrounds the app.

Changes:

  • Add PipReadiness snapshot model + reporting pipeline from FrontendScreenHAApp/HANavHostLaunchActivity/LaunchViewModel
  • Enter PiP from LaunchActivity.onUserLeaveHint() when PiP is supported and the current screen reports eligibility
  • Enable PiP in manifests and add unit/Robolectric test coverage for readiness computation and PiP entry behavior

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
automotive/src/main/AndroidManifest.xml Enables PiP support for Automotive LaunchActivity
automotive/lint-baseline.xml Updates lint baseline metadata/locations and adds a new baseline entry related to the PiP SDK check
app/src/main/AndroidManifest.xml Enables PiP support for app LaunchActivity
app/src/main/kotlin/io/homeassistant/companion/android/launch/LaunchActivity.kt Enters PiP on user-leave when eligible content is reported
app/src/main/kotlin/io/homeassistant/companion/android/launch/LaunchViewModel.kt Stores latest PipReadiness from the UI layer for the activity to read
app/src/main/kotlin/io/homeassistant/companion/android/launch/PipReadiness.kt New model + computation/clamping logic for PiP aspect ratio eligibility
app/src/main/kotlin/io/homeassistant/companion/android/util/compose/HAApp.kt Plumbs onPipReadinessChanged callback into app scaffold/nav host
app/src/main/kotlin/io/homeassistant/companion/android/util/compose/HANavHost.kt Plumbs onPipReadinessChanged into the frontend destination
app/src/main/kotlin/io/homeassistant/companion/android/frontend/navigation/FrontendNavigation.kt Adds onPipReadinessChanged parameter to the frontend route composable
app/src/main/kotlin/io/homeassistant/companion/android/frontend/FrontendScreen.kt Computes and publishes PipReadiness from overlays (custom view / fullscreen player)
app/src/test/kotlin/io/homeassistant/companion/android/launch/LaunchViewModelTest.kt Adds tests for pipReadiness state behavior in the ViewModel
app/src/test/kotlin/io/homeassistant/companion/android/launch/LaunchActivityTest.kt Adds Robolectric tests validating PiP entry behavior on onUserLeaveHint()
app/src/test/kotlin/io/homeassistant/companion/android/frontend/PipReadinessTest.kt Adds Robolectric tests for readiness/aspect clamping logic
app/src/test/kotlin/io/homeassistant/companion/android/frontend/FrontendScreenTest.kt Adds Compose/Robolectric tests ensuring readiness is published from FrontendScreenContent

Comment on lines +215 to +217
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) return
if (!packageManager.hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE)) return
val readiness = viewModel.pipReadiness.value ?: return
@TimoPtr TimoPtr added the WebViewActivity replacement Ongoing work to replace the WebViewActivity in favor of a well tested compose screen using nav. label May 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed WebViewActivity replacement Ongoing work to replace the WebViewActivity in favor of a well tested compose screen using nav.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants